﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
using System.Runtime.Caching;

namespace Ruandao.MiniFace
{
    public class PythonEngine
    {
        readonly static PythonEngine instance = new PythonEngine();

        public static PythonEngine GetInstance()
        {
            return instance;
        }

        public static ScriptEngine GetEngine()
        {
            return instance.python;
        }

        public static ScriptScope CreateScope()
        {
            ScriptScope scope = instance.python.CreateScope();
            if( instance.InitCreateScope !=null )
                instance.InitCreateScope(instance, new ScriptScopeEventArgs(scope));

            return scope;
        }

        public event EventHandler<ScriptScopeEventArgs> InitCreateScope;

        private ScriptEngine python;

        private PythonEngine()
        {
            python = Python.CreateEngine();
        }
    }
}
